package com.demo.app.activiti.controller;

import com.demo.app.activiti.service.ActivitiService;
import model.leave.Leave;
import org.springframework.web.bind.annotation.*;
import result.Result;

import javax.annotation.Resource;

/**
 * @program: couple-game
 * @description: 申请请假工作流
 * @author: fbl
 * @create: 2025-04-11 09:23
 **/
@RestController
@RequestMapping("/api/activiti")
public class ActivitiController {

    @Resource
    ActivitiService activitiService;

    /**
     * 部署流程（流程图画好了，只用启动一次，以后除了改图，再也不需要用了）
     * @return
     */
    @GetMapping(value = "/deployment")
    public Result deployment() {
        return activitiService.deployment();
    }


    /**
     * 普通用户申请请假
     * @return
     */
    @GetMapping(value = "/apply")
    public Result applyLeave(@RequestParam("applyUserId") String applyUserId) {
        return activitiService.applyLeave(applyUserId);
    }

    /**
     * 普通用户提交请假
     * @return
     */
    @PostMapping(value = "/apply/submit")
    public Result applySubmit(@RequestBody Leave leave) {
        return activitiService.applySubmit(leave);
    }

    /**
     * 普通用户查看请假列表
     * @return
     */
    @GetMapping(value = "/apply/list")
    public Result applyLeaveList(@RequestParam String applyUserId ) {
        return activitiService.applyLeaveList(applyUserId);
    }

    /**
     * hr查看用户申请请假列表
     * @return
     */
    @GetMapping(value = "/hr/list")
    public Result hrAuditList(@RequestParam String hrUserId) {
        return activitiService.hrAuditList(hrUserId);
    }

    /**
     * hr审核请假单
     * @return
     */
    @PostMapping(value = "/hr/audit")
    public Result hrAudit(@RequestBody Leave leave) {
        return activitiService.hrAudit(leave);
    }

    /**
     * boss查看用户申请请假列表
     * @return
     */
    @GetMapping(value = "/boss/list")
    public Result bossAuditList(@RequestParam String bossUserId) {
        return activitiService.bossAuditList(bossUserId);
    }

    /**
     * boss审批用户申请请假列表
     * @return
     */
    @PostMapping(value = "/boss/audit")
    public Result bossAudit(@RequestBody Leave leave) {
        return activitiService.bossAudit(leave);
    }

    /**
     * 查看用户申请请假历史记录
     * @return
     */
    @GetMapping(value = "/record")
    public Result record() {
        return activitiService.record();
    }



}
